<template>
    <div>
        <van-nav-bar title="分类" left-text="返回" left-arrow @click-left="($router.push('/home/index'))" />
        <van-row>
            <van-col span="6">
                <van-sidebar v-model="active">
                    <van-sidebar-item v-for="item in categories" :title="item.cat_name" />

                </van-sidebar>

            </van-col>

            <van-col span="18">
                 <lb :images="images" imagewidth="100%" imageheight="200px"></lb>
                <div v-for="item in categories[active]?.children">
                    
                    <h4>{{ item.cat_name }}</h4>
                    <van-grid :column-num="3">
                        <van-grid-item v-for="item in item.children"  :icon="item.cat_icon" :text="item.cat_name" @click="find(item.name)"/>
                    </van-grid>
                </div>
                  

            </van-col>
        </van-row>
          



    </div>
</template>

<script setup>
import lb from '@/components/lb.vue';
const images = [
    'https://fastly.jsdelivr.net/npm/@vant/assets/apple-3.jpeg',
    'https://fastly.jsdelivr.net/npm/@vant/assets/apple-4.jpeg',
];
import { ref } from 'vue';
import { categoriesApi } from '@/api/api';
import router from '@/router';
let categories = ref([])
categoriesApi().then(res => {
    console.log('分类', res)
    categories.value = res.data.message
})
const active = ref(0)
const find=(name)=>{
    router.push({path:'/home/find',params:{name:name}})
}



</script>

<style lang="scss" scoped></style>